<template>
    <div class="Gzdingdan">
        <div class="gzDingdan-xianzhi">
            <el-row>
                <el-col :span="24" class="dingdan-box1" style="border-bottom: 2px solid #E4E4E4">
                    <div class="grid-content bg-purple-dark" style="float: left">
                        订单跟踪
                    </div>
                    <div style="float: right;">
                        <el-button size="mini" style="background-color: #FFFFFF" class="small-button" plain @click="returnPage"><i class="el-icon-arrow-left"></i>返回</el-button>
                        <el-button size="mini" style="background-color: #FFFFFF" class="small-button" @click="shuaxin"><i class="el-icon-refresh-right"></i>刷新</el-button>
                    </div>
                </el-col>
            </el-row>
            <div class="dingdan-box2">
                <span style="float: left;margin-left: 20px">订单跟踪</span>
            </div>
            <div class="dingdan-box3">
                <div style="margin-top: 40px">
                <el-timeline :reverse="reverse">
                    <el-timeline-item
                            v-for="(activity, index) in activities"
                            :key="index"
                            :color="activity.color"
                            :timestamp="activity.gorderdate">
                        {{activity.gorderstatus}}
                    </el-timeline-item>
                </el-timeline>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        inject:['reload'],
        data(){
            return{
                reverse: true,
                activities: [],
            }
        },
        methods:{
            shuaxin(){
                //刷新页面的方法
                this.reload();
            },
            returnPage(){
                //此方法用来返回上一个页面
                if (window.history.length <= 1) {
                    this.$router.push({ path: "/system/storageManagement" });
                    return false;
                } else {
                    this.$router.go(-1);
                }
            },
            async genzongdingdanAll(){
                /*
                * 此方法用来获取跟踪订单的状态
                * */
                const {data:res} = await this.$http.post("/GenzongDingdan",{
                    "orderId":this.$store.state.genzongorderId
                })
                this.activities = res;
                this.activities[this.activities.length-1].color = "#0bbd87"
            },
        },
        mounted() {
            this.genzongdingdanAll();
        }
    }
</script>

<style scoped>
    .Gzdingdan{
        width: 100%;
        height: 100%;
    }
    .gzDingdan-xianzhi{
        width: 1340px;
    }
    .dingdan-box1{
        color: #666666;
        line-height: 50px;
        height: 50px;
        background-color: #F3F3F3;
    }
    .dingdan-box2{
        width: 1000px;
        color: #666666;
        line-height: 40px;
        height: 40px;
        background-color: #F3F3F3;
        margin-top: 20px;
        border: 1px solid #E4E4E4;
    }
    .dingdan-box3{
        width: 1000px;
    }
</style>